package com.hzhr.iot.device.aop.service;

import com.hzhr.iot.device.service.base.BaseService;
import com.hzhr.iot.device.service.util.CheckUtil;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Around;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.util.HashMap;
import java.util.Map;
import com.hzhr.iot.core.constant.Common_ErrorsEnum;
import com.hzhr.iot.core.exception.ServiceException;

@Aspect
@Component
@Order(2)
public class CollectDeviceServiceAspect extends BaseService {
    @Around("execution(* com.hzhr.iot.device.service.CollectDeviceService.get(..))")
    public Object get(ProceedingJoinPoint joinPoint) throws Throwable {
        Object[] args = joinPoint.getArgs();
        Map<String, String> header = (Map<String, String>) args[0];
        if (header == null) {
            header = new HashMap<>();
        }
        Map<String, Object> query = (Map<String, Object>) args[1];
        if (query == null) {
            query = new HashMap<>();
        }


        Map<String, String> headerTmp = new HashMap<>();
        if (!StringUtils.isEmpty(header.get("_hzhr-company-id"))) {
            headerTmp.put("_hzhr-company-id", header.get("_hzhr-company-id"));
        }
        if (!StringUtils.isEmpty(header.get("_hzhr-dept-id"))) {
            headerTmp.put("_hzhr-dept-id", header.get("_hzhr-dept-id"));
        }
        if (!StringUtils.isEmpty(header.get("_hzhr-user-type"))) {
            headerTmp.put("_hzhr-user-type", header.get("_hzhr-user-type"));
        }
        if (!StringUtils.isEmpty(header.get("_hzhr-access-mode"))) {
            headerTmp.put("_hzhr-access-mode", header.get("_hzhr-access-mode"));
        }
        if (!StringUtils.isEmpty(header.get("_hzhr-user-name"))) {
            headerTmp.put("_hzhr-user-name", header.get("_hzhr-user-name"));
        }
        if (!StringUtils.isEmpty(header.get("_token"))) {
            headerTmp.put("_token", header.get("_token"));
        }
        if (!StringUtils.isEmpty(header.get("_hzhr-user-code"))) {
            headerTmp.put("_hzhr-user-code", header.get("_hzhr-user-code"));
        }
        if (!StringUtils.isEmpty(header.get("_hzhr-transaction-id"))) {
            headerTmp.put("_hzhr-transaction-id", header.get("_hzhr-transaction-id"));
        }
        if (!StringUtils.isEmpty(header.get("_hzhr-user-id"))) {
            headerTmp.put("_hzhr-user-id", header.get("_hzhr-user-id"));
        }
        if (!StringUtils.isEmpty(header.get("_hzhr-transaction-type"))) {
            headerTmp.put("_hzhr-transaction-type", header.get("_hzhr-transaction-type"));
        }
        if (!StringUtils.isEmpty(header.get("token"))) {
            headerTmp.put("_token", header.get("token"));
        }

        Map<String, Object> queryTmp = new HashMap<>();
        if (isInternalServiceInvok(headerTmp)) {
            if (!StringUtils.isEmpty(query.get("_page"))) {
                queryTmp.put("_page", query.get("_page"));
            } else if (!StringUtils.isEmpty(query.get("page"))) {
                queryTmp.put("_page", query.get("page"));
            }
            if (!StringUtils.isEmpty(query.get("_lessthan_createTime"))) {
                queryTmp.put("_lessthan_createTime", query.get("_lessthan_createTime"));
            } else if (!StringUtils.isEmpty(query.get("lessthan_createTime"))) {
                queryTmp.put("_lessthan_createTime", query.get("lessthan_createTime"));
            }
            if (!StringUtils.isEmpty(query.get("_equal_prodFactoryIotCompanyId"))) {
                queryTmp.put("_equal_prodFactoryIotCompanyId", query.get("_equal_prodFactoryIotCompanyId"));
            } else if (!StringUtils.isEmpty(query.get("equal_prodFactoryIotCompanyId"))) {
                queryTmp.put("_equal_prodFactoryIotCompanyId", query.get("equal_prodFactoryIotCompanyId"));
            }
            if (!StringUtils.isEmpty(query.get("_like_gasUserAddress"))) {
                queryTmp.put("_like_gasUserAddress", query.get("_like_gasUserAddress"));
            } else if (!StringUtils.isEmpty(query.get("like_gasUserAddress"))) {
                queryTmp.put("_like_gasUserAddress", query.get("like_gasUserAddress"));
            }
            if (!StringUtils.isEmpty(query.get("_show_dept"))) {
                queryTmp.put("_show_dept", query.get("_show_dept"));
            } else if (!StringUtils.isEmpty(query.get("show_dept"))) {
                queryTmp.put("_show_dept", query.get("show_dept"));
            }
            if (!StringUtils.isEmpty(query.get("_like_iotDeviceCode"))) {
                queryTmp.put("_like_iotDeviceCode", query.get("_like_iotDeviceCode"));
            } else if (!StringUtils.isEmpty(query.get("like_iotDeviceCode"))) {
                queryTmp.put("_like_iotDeviceCode", query.get("like_iotDeviceCode"));
            }
            if (!StringUtils.isEmpty(query.get("_equal_iotDeviceId"))) {
                queryTmp.put("_equal_iotDeviceId", query.get("_equal_iotDeviceId"));
            } else if (!StringUtils.isEmpty(query.get("equal_iotDeviceId"))) {
                queryTmp.put("_equal_iotDeviceId", query.get("equal_iotDeviceId"));
            }
            if (!StringUtils.isEmpty(query.get("_equal_iotDeviceCompanyName"))) {
                queryTmp.put("_equal_iotDeviceCompanyName", query.get("_equal_iotDeviceCompanyName"));
            } else if (!StringUtils.isEmpty(query.get("equal_iotDeviceCompanyName"))) {
                queryTmp.put("_equal_iotDeviceCompanyName", query.get("equal_iotDeviceCompanyName"));
            }
            if (!StringUtils.isEmpty(query.get("_show_total"))) {
                queryTmp.put("_show_total", query.get("_show_total"));
            } else if (!StringUtils.isEmpty(query.get("show_total"))) {
                queryTmp.put("_show_total", query.get("show_total"));
            }
            if (!StringUtils.isEmpty(query.get("_show_outId"))) {
                queryTmp.put("_show_outId", query.get("_show_outId"));
            } else if (!StringUtils.isEmpty(query.get("show_outId"))) {
                queryTmp.put("_show_outId", query.get("show_outId"));
            }
            if (!StringUtils.isEmpty(query.get("_equal_gasUserId"))) {
                queryTmp.put("_equal_gasUserId", query.get("_equal_gasUserId"));
            } else if (!StringUtils.isEmpty(query.get("equal_gasUserId"))) {
                queryTmp.put("_equal_gasUserId", query.get("equal_gasUserId"));
            }
            if (!StringUtils.isEmpty(query.get("_like_deptCode"))) {
                queryTmp.put("_like_deptCode", query.get("_like_deptCode"));
            } else if (!StringUtils.isEmpty(query.get("like_deptCode"))) {
                queryTmp.put("_like_deptCode", query.get("like_deptCode"));
            }
            if (!StringUtils.isEmpty(query.get("_greaterthanorequal_createTime"))) {
                queryTmp.put("_greaterthanorequal_createTime", query.get("_greaterthanorequal_createTime"));
            } else if (!StringUtils.isEmpty(query.get("greaterthanorequal_createTime"))) {
                queryTmp.put("_greaterthanorequal_createTime", query.get("greaterthanorequal_createTime"));
            }
            if (!StringUtils.isEmpty(query.get("_equal_prodFactoryId"))) {
                queryTmp.put("_equal_prodFactoryId", query.get("_equal_prodFactoryId"));
            } else if (!StringUtils.isEmpty(query.get("equal_prodFactoryId"))) {
                queryTmp.put("_equal_prodFactoryId", query.get("equal_prodFactoryId"));
            }
            if (!StringUtils.isEmpty(query.get("_show"))) {
                queryTmp.put("_show", query.get("_show"));
            } else if (!StringUtils.isEmpty(query.get("show"))) {
                queryTmp.put("_show", query.get("show"));
            }
            if (!StringUtils.isEmpty(query.get("_show_gasConsume"))) {
                queryTmp.put("_show_gasConsume", query.get("_show_gasConsume"));
            } else if (!StringUtils.isEmpty(query.get("show_gasConsume"))) {
                queryTmp.put("_show_gasConsume", query.get("show_gasConsume"));
            }
            if (!StringUtils.isEmpty(query.get("_equal_companyId"))) {
                queryTmp.put("_equal_companyId", query.get("_equal_companyId"));
            } else if (!StringUtils.isEmpty(query.get("equal_companyId"))) {
                queryTmp.put("_equal_companyId", query.get("equal_companyId"));
            }
            if (!StringUtils.isEmpty(query.get("_like_gasUserName"))) {
                queryTmp.put("_like_gasUserName", query.get("_like_gasUserName"));
            } else if (!StringUtils.isEmpty(query.get("like_gasUserName"))) {
                queryTmp.put("_like_gasUserName", query.get("like_gasUserName"));
            }
            if (!StringUtils.isEmpty(query.get("_is_paging"))) {
                queryTmp.put("_is_paging", query.get("_is_paging"));
            } else if (!StringUtils.isEmpty(query.get("is_paging"))) {
                queryTmp.put("_is_paging", query.get("is_paging"));
            }
            if (!StringUtils.isEmpty(query.get("_show_gasUser"))) {
                queryTmp.put("_show_gasUser", query.get("_show_gasUser"));
            } else if (!StringUtils.isEmpty(query.get("show_gasUser"))) {
                queryTmp.put("_show_gasUser", query.get("show_gasUser"));
            }
            if (!StringUtils.isEmpty(query.get("_equal_code"))) {
                queryTmp.put("_equal_code", query.get("_equal_code"));
            } else if (!StringUtils.isEmpty(query.get("equal_code"))) {
                queryTmp.put("_equal_code", query.get("equal_code"));
            }
            if (!StringUtils.isEmpty(query.get("_count"))) {
                queryTmp.put("_count", query.get("_count"));
            } else if (!StringUtils.isEmpty(query.get("count"))) {
                queryTmp.put("_count", query.get("count"));
            }
            if (!StringUtils.isEmpty(query.get("_equal_gasUserCode"))) {
                queryTmp.put("_equal_gasUserCode", query.get("_equal_gasUserCode"));
            } else if (!StringUtils.isEmpty(query.get("equal_gasUserCode"))) {
                queryTmp.put("_equal_gasUserCode", query.get("equal_gasUserCode"));
            }
            if (!StringUtils.isEmpty(query.get("_show_iotDevice"))) {
                queryTmp.put("_show_iotDevice", query.get("_show_iotDevice"));
            } else if (!StringUtils.isEmpty(query.get("show_iotDevice"))) {
                queryTmp.put("_show_iotDevice", query.get("show_iotDevice"));
            }
            if (!StringUtils.isEmpty(query.get("_equal_iotDeviceCompanyId"))) {
                queryTmp.put("_equal_iotDeviceCompanyId", query.get("_equal_iotDeviceCompanyId"));
            } else if (!StringUtils.isEmpty(query.get("equal_iotDeviceCompanyId"))) {
                queryTmp.put("_equal_iotDeviceCompanyId", query.get("equal_iotDeviceCompanyId"));
            }
            if (!StringUtils.isEmpty(query.get("_like_gasUserCode"))) {
                queryTmp.put("_like_gasUserCode", query.get("_like_gasUserCode"));
            } else if (!StringUtils.isEmpty(query.get("like_gasUserCode"))) {
                queryTmp.put("_like_gasUserCode", query.get("like_gasUserCode"));
            }
            if (!StringUtils.isEmpty(query.get("_equal_id"))) {
                queryTmp.put("_equal_id", query.get("_equal_id"));
            } else if (!StringUtils.isEmpty(query.get("equal_id"))) {
                queryTmp.put("_equal_id", query.get("equal_id"));
            }
            if (!StringUtils.isEmpty(query.get("_like_code"))) {
                queryTmp.put("_like_code", query.get("_like_code"));
            } else if (!StringUtils.isEmpty(query.get("like_code"))) {
                queryTmp.put("_like_code", query.get("like_code"));
            }
            if (!StringUtils.isEmpty(query.get("_show_type"))) {
                queryTmp.put("_show_type", query.get("_show_type"));
            } else if (!StringUtils.isEmpty(query.get("show_type"))) {
                queryTmp.put("_show_type", query.get("show_type"));
            }
            if (!StringUtils.isEmpty(query.get("_equal_deptId"))) {
                queryTmp.put("_equal_deptId", query.get("_equal_deptId"));
            } else if (!StringUtils.isEmpty(query.get("equal_deptId"))) {
                queryTmp.put("_equal_deptId", query.get("equal_deptId"));
            }
            if (!StringUtils.isEmpty(query.get("_equal_deptCode"))) {
                queryTmp.put("_equal_deptCode", query.get("_equal_deptCode"));
            } else if (!StringUtils.isEmpty(query.get("equal_deptCode"))) {
                queryTmp.put("_equal_deptCode", query.get("equal_deptCode"));
            }
            if (!StringUtils.isEmpty(query.get("_equal_categoryCode"))) {
                queryTmp.put("_equal_categoryCode", query.get("_equal_categoryCode"));
            } else if (!StringUtils.isEmpty(query.get("equal_categoryCode"))) {
                queryTmp.put("_equal_categoryCode", query.get("equal_categoryCode"));
            }
            if (!StringUtils.isEmpty(query.get("_show_info"))) {
                queryTmp.put("_show_info", query.get("_show_info"));
            } else if (!StringUtils.isEmpty(query.get("show_info"))) {
                queryTmp.put("_show_info", query.get("show_info"));
            }
            if (!StringUtils.isEmpty(query.get("_show_alarmCount"))) {
                queryTmp.put("_show_alarmCount", query.get("_show_alarmCount"));
            } else if (!StringUtils.isEmpty(query.get("show_alarmCount"))) {
                queryTmp.put("_show_alarmCount", query.get("show_alarmCount"));
            }
        } else {
            if (!StringUtils.isEmpty(query.get("equal_deptCode"))) {
                queryTmp.put("_equal_deptCode", query.get("equal_deptCode"));
            }
            if (!StringUtils.isEmpty(query.get("equal_companyId"))) {
                queryTmp.put("_equal_companyId", query.get("equal_companyId"));
            }
            if (!StringUtils.isEmpty(query.get("equal_gasUserId"))) {
                queryTmp.put("_equal_gasUserId", query.get("equal_gasUserId"));
            }
            if (!StringUtils.isEmpty(query.get("show_iotDevice"))) {
                queryTmp.put("_show_iotDevice", query.get("show_iotDevice"));
            }
            if (!StringUtils.isEmpty(query.get("show_gasUser"))) {
                queryTmp.put("_show_gasUser", query.get("show_gasUser"));
            }
            if (!StringUtils.isEmpty(query.get("equal_code"))) {
                queryTmp.put("_equal_code", query.get("equal_code"));
            }
            if (!StringUtils.isEmpty(query.get("equal_iotDeviceCompanyName"))) {
                queryTmp.put("_equal_iotDeviceCompanyName", query.get("equal_iotDeviceCompanyName"));
            }
            if (!StringUtils.isEmpty(query.get("show_gasConsume"))) {
                queryTmp.put("_show_gasConsume", query.get("show_gasConsume"));
            }
            if (!StringUtils.isEmpty(query.get("show_alarmCount"))) {
                queryTmp.put("_show_alarmCount", query.get("show_alarmCount"));
            }
            if (!StringUtils.isEmpty(query.get("equal_id"))) {
                queryTmp.put("_equal_id", query.get("equal_id"));
            }
            if (!StringUtils.isEmpty(query.get("like_code"))) {
                queryTmp.put("_like_code", query.get("like_code"));
            }
            if (!StringUtils.isEmpty(query.get("like_gasUserName"))) {
                queryTmp.put("_like_gasUserName", query.get("like_gasUserName"));
            }
            if (!StringUtils.isEmpty(query.get("show_total"))) {
                queryTmp.put("_show_total", query.get("show_total"));
            }
            if (!StringUtils.isEmpty(query.get("like_iotDeviceCode"))) {
                queryTmp.put("_like_iotDeviceCode", query.get("like_iotDeviceCode"));
            }
            if (!StringUtils.isEmpty(query.get("show_outId"))) {
                queryTmp.put("_show_outId", query.get("show_outId"));
            }
            if (!StringUtils.isEmpty(query.get("count"))) {
                queryTmp.put("_count", query.get("count"));
            }
            if (!StringUtils.isEmpty(query.get("show_type"))) {
                queryTmp.put("_show_type", query.get("show_type"));
            }
            if (!StringUtils.isEmpty(query.get("greaterthanorequal_createTime"))) {
                queryTmp.put("_greaterthanorequal_createTime", query.get("greaterthanorequal_createTime"));
            }
            if (!StringUtils.isEmpty(query.get("equal_gasUserCode"))) {
                queryTmp.put("_equal_gasUserCode", query.get("equal_gasUserCode"));
            }
            if (!StringUtils.isEmpty(query.get("show_info"))) {
                queryTmp.put("_show_info", query.get("show_info"));
            }
            if (!StringUtils.isEmpty(query.get("page"))) {
                queryTmp.put("_page", query.get("page"));
            }
            if (!StringUtils.isEmpty(query.get("equal_iotDeviceId"))) {
                queryTmp.put("_equal_iotDeviceId", query.get("equal_iotDeviceId"));
            }
            if (!StringUtils.isEmpty(query.get("show_dept"))) {
                queryTmp.put("_show_dept", query.get("show_dept"));
            }
            if (!StringUtils.isEmpty(query.get("show"))) {
                queryTmp.put("_show", query.get("show"));
            }
            if (!StringUtils.isEmpty(query.get("lessthan_createTime"))) {
                queryTmp.put("_lessthan_createTime", query.get("lessthan_createTime"));
            }
            if (!StringUtils.isEmpty(query.get("equal_categoryCode"))) {
                queryTmp.put("_equal_categoryCode", query.get("equal_categoryCode"));
            }
            if (!StringUtils.isEmpty(query.get("like_gasUserAddress"))) {
                queryTmp.put("_like_gasUserAddress", query.get("like_gasUserAddress"));
            }
            if (!StringUtils.isEmpty(query.get("equal_iotDeviceCompanyId"))) {
                queryTmp.put("_equal_iotDeviceCompanyId", query.get("equal_iotDeviceCompanyId"));
            }
            if (!StringUtils.isEmpty(query.get("equal_prodFactoryId"))) {
                queryTmp.put("_equal_prodFactoryId", query.get("equal_prodFactoryId"));
            }
            if (!StringUtils.isEmpty(query.get("equal_prodFactoryIotCompanyId"))) {
                queryTmp.put("_equal_prodFactoryIotCompanyId", query.get("equal_prodFactoryIotCompanyId"));
            }
            if (!StringUtils.isEmpty(query.get("equal_deptId"))) {
                queryTmp.put("_equal_deptId", query.get("equal_deptId"));
            }
            if (!StringUtils.isEmpty(query.get("like_gasUserCode"))) {
                queryTmp.put("_like_gasUserCode", query.get("like_gasUserCode"));
            }
            if (!StringUtils.isEmpty(query.get("like_deptCode"))) {
                queryTmp.put("_like_deptCode", query.get("like_deptCode"));
            }
        }

        if (isInternalServiceInvok(headerTmp)) {
            if (StringUtils.isEmpty(headerTmp.get("_token"))) {
                Map<String, Object> objectInfo = new HashMap<>();
                objectInfo.put("header", headerTmp);
                throw new ServiceException(Common_ErrorsEnum.COMMON_6, "header._token不能为空", objectInfo);
            }
            if (StringUtils.isEmpty(headerTmp.get("_hzhr-user-id"))) {
                Map<String, Object> objectInfo = new HashMap<>();
                objectInfo.put("header", headerTmp);
                throw new ServiceException(Common_ErrorsEnum.COMMON_6, "header._hzhr-user-id不能为空", objectInfo);
            }
            if (StringUtils.isEmpty(headerTmp.get("_hzhr-user-code"))) {
                Map<String, Object> objectInfo = new HashMap<>();
                objectInfo.put("header", headerTmp);
                throw new ServiceException(Common_ErrorsEnum.COMMON_6, "header._hzhr-user-code不能为空", objectInfo);
            }
            if (StringUtils.isEmpty(headerTmp.get("_hzhr-user-name"))) {
                Map<String, Object> objectInfo = new HashMap<>();
                objectInfo.put("header", headerTmp);
                throw new ServiceException(Common_ErrorsEnum.COMMON_6, "header._hzhr-user-name不能为空", objectInfo);
            }
            if (StringUtils.isEmpty(headerTmp.get("_hzhr-company-id"))) {
                Map<String, Object> objectInfo = new HashMap<>();
                objectInfo.put("header", headerTmp);
                throw new ServiceException(Common_ErrorsEnum.COMMON_6, "header._hzhr-company-id不能为空", objectInfo);
            }
            if (StringUtils.isEmpty(headerTmp.get("_hzhr-dept-id"))) {
                Map<String, Object> objectInfo = new HashMap<>();
                objectInfo.put("header", headerTmp);
                throw new ServiceException(Common_ErrorsEnum.COMMON_6, "header._hzhr-dept-id不能为空", objectInfo);
            }
            if (StringUtils.isEmpty(headerTmp.get("_hzhr-user-type"))) {
                Map<String, Object> objectInfo = new HashMap<>();
                objectInfo.put("header", headerTmp);
                throw new ServiceException(Common_ErrorsEnum.COMMON_6, "header._hzhr-user-type不能为空", objectInfo);
            }
            if (StringUtils.isEmpty(headerTmp.get("_hzhr-transaction-id"))) {
                Map<String, Object> objectInfo = new HashMap<>();
                objectInfo.put("header", headerTmp);
                throw new ServiceException(Common_ErrorsEnum.COMMON_6, "header._hzhr-transaction-id不能为空", objectInfo);
            }
            if (StringUtils.isEmpty(headerTmp.get("_hzhr-transaction-type"))) {
                Map<String, Object> objectInfo = new HashMap<>();
                objectInfo.put("header", headerTmp);
                throw new ServiceException(Common_ErrorsEnum.COMMON_6, "header._hzhr-transaction-type不能为空", objectInfo);
            }
            if (StringUtils.isEmpty(headerTmp.get("_hzhr-access-mode"))) {
                headerTmp.put("_hzhr-access-mode", "0");
            }
            if (StringUtils.isEmpty(queryTmp.get("_show_total"))) {
                queryTmp.put("_show_total", "false");
            }
            if (StringUtils.isEmpty(queryTmp.get("_show_info"))) {
                queryTmp.put("_show_info", "false");
            }
            if (StringUtils.isEmpty(queryTmp.get("_show_type"))) {
                queryTmp.put("_show_type", "false");
            }
            if (StringUtils.isEmpty(queryTmp.get("_show_iotDevice"))) {
                queryTmp.put("_show_iotDevice", "false");
            }
            if (StringUtils.isEmpty(queryTmp.get("_show_gasUser"))) {
                queryTmp.put("_show_gasUser", "false");
            }
            if (StringUtils.isEmpty(queryTmp.get("_show_gasConsume"))) {
                queryTmp.put("_show_gasConsume", "false");
            }
            if (StringUtils.isEmpty(queryTmp.get("_show_alarmCount"))) {
                queryTmp.put("_show_alarmCount", "false");
            }
            if (StringUtils.isEmpty(queryTmp.get("_show_dept"))) {
                queryTmp.put("_show_dept", "false");
            }
            if (StringUtils.isEmpty(queryTmp.get("_show_outId"))) {
                queryTmp.put("_show_outId", "false");
            }
            if (StringUtils.isEmpty(queryTmp.get("_is_paging"))) {
                queryTmp.put("_is_paging", "true");
            }
            if (StringUtils.isEmpty(queryTmp.get("_page"))) {
                queryTmp.put("_page", "1");
            }
            if (StringUtils.isEmpty(queryTmp.get("_count"))) {
                queryTmp.put("_count", "1");
            }
        } else {
            if (StringUtils.isEmpty(headerTmp.get("_token"))) {
                Map<String, Object> objectInfo = new HashMap<>();
                objectInfo.put("header", headerTmp);
                throw new ServiceException(Common_ErrorsEnum.COMMON_6, "header.token不能为空", objectInfo);
            }
            if (StringUtils.isEmpty(queryTmp.get("_show_total"))) {
                queryTmp.put("_show_total", "false");
            }
            if (StringUtils.isEmpty(queryTmp.get("_show_info"))) {
                queryTmp.put("_show_info", "false");
            }
            if (StringUtils.isEmpty(queryTmp.get("_show_type"))) {
                queryTmp.put("_show_type", "false");
            }
            if (StringUtils.isEmpty(queryTmp.get("_show_iotDevice"))) {
                queryTmp.put("_show_iotDevice", "false");
            }
            if (StringUtils.isEmpty(queryTmp.get("_show_gasUser"))) {
                queryTmp.put("_show_gasUser", "false");
            }
            if (StringUtils.isEmpty(queryTmp.get("_show_gasConsume"))) {
                queryTmp.put("_show_gasConsume", "false");
            }
            if (StringUtils.isEmpty(queryTmp.get("_show_alarmCount"))) {
                queryTmp.put("_show_alarmCount", "false");
            }
            if (StringUtils.isEmpty(queryTmp.get("_show_dept"))) {
                queryTmp.put("_show_dept", "false");
            }
            if (StringUtils.isEmpty(queryTmp.get("_show_outId"))) {
                queryTmp.put("_show_outId", "false");
            }
            if (StringUtils.isEmpty(queryTmp.get("_page"))) {
                queryTmp.put("_page", "1");
            }
            if (StringUtils.isEmpty(queryTmp.get("_count"))) {
                queryTmp.put("_count", "1");
            }
        }

        if (!StringUtils.isEmpty(queryTmp.get("_is_paging")) && !Boolean.parseBoolean(queryTmp.get("_is_paging").toString())) {
            queryTmp.put("_page", null);
            queryTmp.put("_count", null);
        }
        args[1] = queryTmp;
        args[0] = headerTmp;
        return joinPoint.proceed(args);
    }
    @Around("execution(* com.hzhr.iot.device.service.CollectDeviceService.get2(..))")
    public Object get2(ProceedingJoinPoint joinPoint) throws Throwable {
        Object[] args = joinPoint.getArgs();
        Map<String, String> header = (Map<String, String>) args[0];
        if (header == null) {
            header = new HashMap<>();
        }
        Map<String, Object> query = (Map<String, Object>) args[1];
        if (query == null) {
            query = new HashMap<>();
        }


        Map<String, String> headerTmp = new HashMap<>();
        if (!StringUtils.isEmpty(header.get("_hzhr-company-id"))) {
            headerTmp.put("_hzhr-company-id", header.get("_hzhr-company-id"));
        }
        if (!StringUtils.isEmpty(header.get("_hzhr-dept-id"))) {
            headerTmp.put("_hzhr-dept-id", header.get("_hzhr-dept-id"));
        }
        if (!StringUtils.isEmpty(header.get("_hzhr-user-type"))) {
            headerTmp.put("_hzhr-user-type", header.get("_hzhr-user-type"));
        }
        if (!StringUtils.isEmpty(header.get("_hzhr-access-mode"))) {
            headerTmp.put("_hzhr-access-mode", header.get("_hzhr-access-mode"));
        }
        if (!StringUtils.isEmpty(header.get("_hzhr-user-name"))) {
            headerTmp.put("_hzhr-user-name", header.get("_hzhr-user-name"));
        }
        if (!StringUtils.isEmpty(header.get("_token"))) {
            headerTmp.put("_token", header.get("_token"));
        }
        if (!StringUtils.isEmpty(header.get("_hzhr-user-code"))) {
            headerTmp.put("_hzhr-user-code", header.get("_hzhr-user-code"));
        }
        if (!StringUtils.isEmpty(header.get("_hzhr-transaction-id"))) {
            headerTmp.put("_hzhr-transaction-id", header.get("_hzhr-transaction-id"));
        }
        if (!StringUtils.isEmpty(header.get("_hzhr-user-id"))) {
            headerTmp.put("_hzhr-user-id", header.get("_hzhr-user-id"));
        }
        if (!StringUtils.isEmpty(header.get("_hzhr-transaction-type"))) {
            headerTmp.put("_hzhr-transaction-type", header.get("_hzhr-transaction-type"));
        }
        if (!StringUtils.isEmpty(header.get("token"))) {
            headerTmp.put("_token", header.get("token"));
        }

        Map<String, Object> queryTmp = new HashMap<>();
        if (isInternalServiceInvok(headerTmp)) {
            if (!StringUtils.isEmpty(query.get("_page"))) {
                queryTmp.put("_page", query.get("_page"));
            } else if (!StringUtils.isEmpty(query.get("page"))) {
                queryTmp.put("_page", query.get("page"));
            }
            if (!StringUtils.isEmpty(query.get("_lessthan_createTime"))) {
                queryTmp.put("_lessthan_createTime", query.get("_lessthan_createTime"));
            } else if (!StringUtils.isEmpty(query.get("lessthan_createTime"))) {
                queryTmp.put("_lessthan_createTime", query.get("lessthan_createTime"));
            }
            if (!StringUtils.isEmpty(query.get("_like_gasUserAddress"))) {
                queryTmp.put("_like_gasUserAddress", query.get("_like_gasUserAddress"));
            } else if (!StringUtils.isEmpty(query.get("like_gasUserAddress"))) {
                queryTmp.put("_like_gasUserAddress", query.get("like_gasUserAddress"));
            }
            if (!StringUtils.isEmpty(query.get("_show_dept"))) {
                queryTmp.put("_show_dept", query.get("_show_dept"));
            } else if (!StringUtils.isEmpty(query.get("show_dept"))) {
                queryTmp.put("_show_dept", query.get("show_dept"));
            }
            if (!StringUtils.isEmpty(query.get("_like_iotDeviceCode"))) {
                queryTmp.put("_like_iotDeviceCode", query.get("_like_iotDeviceCode"));
            } else if (!StringUtils.isEmpty(query.get("like_iotDeviceCode"))) {
                queryTmp.put("_like_iotDeviceCode", query.get("like_iotDeviceCode"));
            }
            if (!StringUtils.isEmpty(query.get("_equal_iotDeviceId"))) {
                queryTmp.put("_equal_iotDeviceId", query.get("_equal_iotDeviceId"));
            } else if (!StringUtils.isEmpty(query.get("equal_iotDeviceId"))) {
                queryTmp.put("_equal_iotDeviceId", query.get("equal_iotDeviceId"));
            }
            if (!StringUtils.isEmpty(query.get("_show_total"))) {
                queryTmp.put("_show_total", query.get("_show_total"));
            } else if (!StringUtils.isEmpty(query.get("show_total"))) {
                queryTmp.put("_show_total", query.get("show_total"));
            }
            if (!StringUtils.isEmpty(query.get("_equal_gasUserId"))) {
                queryTmp.put("_equal_gasUserId", query.get("_equal_gasUserId"));
            } else if (!StringUtils.isEmpty(query.get("equal_gasUserId"))) {
                queryTmp.put("_equal_gasUserId", query.get("equal_gasUserId"));
            }
            if (!StringUtils.isEmpty(query.get("_greaterthanorequal_createTime"))) {
                queryTmp.put("_greaterthanorequal_createTime", query.get("_greaterthanorequal_createTime"));
            } else if (!StringUtils.isEmpty(query.get("greaterthanorequal_createTime"))) {
                queryTmp.put("_greaterthanorequal_createTime", query.get("greaterthanorequal_createTime"));
            }
            if (!StringUtils.isEmpty(query.get("_show"))) {
                queryTmp.put("_show", query.get("_show"));
            } else if (!StringUtils.isEmpty(query.get("show"))) {
                queryTmp.put("_show", query.get("show"));
            }
            if (!StringUtils.isEmpty(query.get("_show_gasConsume"))) {
                queryTmp.put("_show_gasConsume", query.get("_show_gasConsume"));
            } else if (!StringUtils.isEmpty(query.get("show_gasConsume"))) {
                queryTmp.put("_show_gasConsume", query.get("show_gasConsume"));
            }
            if (!StringUtils.isEmpty(query.get("_equal_companyId"))) {
                queryTmp.put("_equal_companyId", query.get("_equal_companyId"));
            } else if (!StringUtils.isEmpty(query.get("equal_companyId"))) {
                queryTmp.put("_equal_companyId", query.get("equal_companyId"));
            }
            if (!StringUtils.isEmpty(query.get("_like_gasUserName"))) {
                queryTmp.put("_like_gasUserName", query.get("_like_gasUserName"));
            } else if (!StringUtils.isEmpty(query.get("like_gasUserName"))) {
                queryTmp.put("_like_gasUserName", query.get("like_gasUserName"));
            }
            if (!StringUtils.isEmpty(query.get("_is_paging"))) {
                queryTmp.put("_is_paging", query.get("_is_paging"));
            } else if (!StringUtils.isEmpty(query.get("is_paging"))) {
                queryTmp.put("_is_paging", query.get("is_paging"));
            }
            if (!StringUtils.isEmpty(query.get("_show_gasUser"))) {
                queryTmp.put("_show_gasUser", query.get("_show_gasUser"));
            } else if (!StringUtils.isEmpty(query.get("show_gasUser"))) {
                queryTmp.put("_show_gasUser", query.get("show_gasUser"));
            }
            if (!StringUtils.isEmpty(query.get("_equal_code"))) {
                queryTmp.put("_equal_code", query.get("_equal_code"));
            } else if (!StringUtils.isEmpty(query.get("equal_code"))) {
                queryTmp.put("_equal_code", query.get("equal_code"));
            }
            if (!StringUtils.isEmpty(query.get("_count"))) {
                queryTmp.put("_count", query.get("_count"));
            } else if (!StringUtils.isEmpty(query.get("count"))) {
                queryTmp.put("_count", query.get("count"));
            }
            if (!StringUtils.isEmpty(query.get("_equal_gasUserCode"))) {
                queryTmp.put("_equal_gasUserCode", query.get("_equal_gasUserCode"));
            } else if (!StringUtils.isEmpty(query.get("equal_gasUserCode"))) {
                queryTmp.put("_equal_gasUserCode", query.get("equal_gasUserCode"));
            }
            if (!StringUtils.isEmpty(query.get("_show_iotDevice"))) {
                queryTmp.put("_show_iotDevice", query.get("_show_iotDevice"));
            } else if (!StringUtils.isEmpty(query.get("show_iotDevice"))) {
                queryTmp.put("_show_iotDevice", query.get("show_iotDevice"));
            }
            if (!StringUtils.isEmpty(query.get("_like_gasUserCode"))) {
                queryTmp.put("_like_gasUserCode", query.get("_like_gasUserCode"));
            } else if (!StringUtils.isEmpty(query.get("like_gasUserCode"))) {
                queryTmp.put("_like_gasUserCode", query.get("like_gasUserCode"));
            }
            if (!StringUtils.isEmpty(query.get("_equal_id"))) {
                queryTmp.put("_equal_id", query.get("_equal_id"));
            } else if (!StringUtils.isEmpty(query.get("equal_id"))) {
                queryTmp.put("_equal_id", query.get("equal_id"));
            }
            if (!StringUtils.isEmpty(query.get("_like_code"))) {
                queryTmp.put("_like_code", query.get("_like_code"));
            } else if (!StringUtils.isEmpty(query.get("like_code"))) {
                queryTmp.put("_like_code", query.get("like_code"));
            }
            if (!StringUtils.isEmpty(query.get("_show_type"))) {
                queryTmp.put("_show_type", query.get("_show_type"));
            } else if (!StringUtils.isEmpty(query.get("show_type"))) {
                queryTmp.put("_show_type", query.get("show_type"));
            }
            if (!StringUtils.isEmpty(query.get("_equal_deptId"))) {
                queryTmp.put("_equal_deptId", query.get("_equal_deptId"));
            } else if (!StringUtils.isEmpty(query.get("equal_deptId"))) {
                queryTmp.put("_equal_deptId", query.get("equal_deptId"));
            }
            if (!StringUtils.isEmpty(query.get("_equal_deptCode"))) {
                queryTmp.put("_equal_deptCode", query.get("_equal_deptCode"));
            } else if (!StringUtils.isEmpty(query.get("equal_deptCode"))) {
                queryTmp.put("_equal_deptCode", query.get("equal_deptCode"));
            }
            if (!StringUtils.isEmpty(query.get("_equal_categoryCode"))) {
                queryTmp.put("_equal_categoryCode", query.get("_equal_categoryCode"));
            } else if (!StringUtils.isEmpty(query.get("equal_categoryCode"))) {
                queryTmp.put("_equal_categoryCode", query.get("equal_categoryCode"));
            }
            if (!StringUtils.isEmpty(query.get("_show_info"))) {
                queryTmp.put("_show_info", query.get("_show_info"));
            } else if (!StringUtils.isEmpty(query.get("show_info"))) {
                queryTmp.put("_show_info", query.get("show_info"));
            }
            if (!StringUtils.isEmpty(query.get("_show_alarmCount"))) {
                queryTmp.put("_show_alarmCount", query.get("_show_alarmCount"));
            } else if (!StringUtils.isEmpty(query.get("show_alarmCount"))) {
                queryTmp.put("_show_alarmCount", query.get("show_alarmCount"));
            }
        } else {
            if (!StringUtils.isEmpty(query.get("equal_deptCode"))) {
                queryTmp.put("_equal_deptCode", query.get("equal_deptCode"));
            }
            if (!StringUtils.isEmpty(query.get("equal_companyId"))) {
                queryTmp.put("_equal_companyId", query.get("equal_companyId"));
            }
            if (!StringUtils.isEmpty(query.get("equal_gasUserId"))) {
                queryTmp.put("_equal_gasUserId", query.get("equal_gasUserId"));
            }
            if (!StringUtils.isEmpty(query.get("show_iotDevice"))) {
                queryTmp.put("_show_iotDevice", query.get("show_iotDevice"));
            }
            if (!StringUtils.isEmpty(query.get("show_gasUser"))) {
                queryTmp.put("_show_gasUser", query.get("show_gasUser"));
            }
            if (!StringUtils.isEmpty(query.get("equal_code"))) {
                queryTmp.put("_equal_code", query.get("equal_code"));
            }
            if (!StringUtils.isEmpty(query.get("show_gasConsume"))) {
                queryTmp.put("_show_gasConsume", query.get("show_gasConsume"));
            }
            if (!StringUtils.isEmpty(query.get("show_alarmCount"))) {
                queryTmp.put("_show_alarmCount", query.get("show_alarmCount"));
            }
            if (!StringUtils.isEmpty(query.get("equal_id"))) {
                queryTmp.put("_equal_id", query.get("equal_id"));
            }
            if (!StringUtils.isEmpty(query.get("like_code"))) {
                queryTmp.put("_like_code", query.get("like_code"));
            }
            if (!StringUtils.isEmpty(query.get("like_gasUserName"))) {
                queryTmp.put("_like_gasUserName", query.get("like_gasUserName"));
            }
            if (!StringUtils.isEmpty(query.get("show_total"))) {
                queryTmp.put("_show_total", query.get("show_total"));
            }
            if (!StringUtils.isEmpty(query.get("like_iotDeviceCode"))) {
                queryTmp.put("_like_iotDeviceCode", query.get("like_iotDeviceCode"));
            }
            if (!StringUtils.isEmpty(query.get("count"))) {
                queryTmp.put("_count", query.get("count"));
            }
            if (!StringUtils.isEmpty(query.get("show_type"))) {
                queryTmp.put("_show_type", query.get("show_type"));
            }
            if (!StringUtils.isEmpty(query.get("greaterthanorequal_createTime"))) {
                queryTmp.put("_greaterthanorequal_createTime", query.get("greaterthanorequal_createTime"));
            }
            if (!StringUtils.isEmpty(query.get("equal_gasUserCode"))) {
                queryTmp.put("_equal_gasUserCode", query.get("equal_gasUserCode"));
            }
            if (!StringUtils.isEmpty(query.get("show_info"))) {
                queryTmp.put("_show_info", query.get("show_info"));
            }
            if (!StringUtils.isEmpty(query.get("page"))) {
                queryTmp.put("_page", query.get("page"));
            }
            if (!StringUtils.isEmpty(query.get("equal_iotDeviceId"))) {
                queryTmp.put("_equal_iotDeviceId", query.get("equal_iotDeviceId"));
            }
            if (!StringUtils.isEmpty(query.get("show_dept"))) {
                queryTmp.put("_show_dept", query.get("show_dept"));
            }
            if (!StringUtils.isEmpty(query.get("show"))) {
                queryTmp.put("_show", query.get("show"));
            }
            if (!StringUtils.isEmpty(query.get("lessthan_createTime"))) {
                queryTmp.put("_lessthan_createTime", query.get("lessthan_createTime"));
            }
            if (!StringUtils.isEmpty(query.get("equal_categoryCode"))) {
                queryTmp.put("_equal_categoryCode", query.get("equal_categoryCode"));
            }
            if (!StringUtils.isEmpty(query.get("like_gasUserAddress"))) {
                queryTmp.put("_like_gasUserAddress", query.get("like_gasUserAddress"));
            }
            if (!StringUtils.isEmpty(query.get("equal_deptId"))) {
                queryTmp.put("_equal_deptId", query.get("equal_deptId"));
            }
            if (!StringUtils.isEmpty(query.get("like_gasUserCode"))) {
                queryTmp.put("_like_gasUserCode", query.get("like_gasUserCode"));
            }
        }

        if (isInternalServiceInvok(headerTmp)) {
            if (StringUtils.isEmpty(headerTmp.get("_token"))) {
                Map<String, Object> objectInfo = new HashMap<>();
                objectInfo.put("header", headerTmp);
                throw new ServiceException(Common_ErrorsEnum.COMMON_6, "header._token不能为空", objectInfo);
            }
            if (StringUtils.isEmpty(headerTmp.get("_hzhr-user-id"))) {
                Map<String, Object> objectInfo = new HashMap<>();
                objectInfo.put("header", headerTmp);
                throw new ServiceException(Common_ErrorsEnum.COMMON_6, "header._hzhr-user-id不能为空", objectInfo);
            }
            if (StringUtils.isEmpty(headerTmp.get("_hzhr-user-code"))) {
                Map<String, Object> objectInfo = new HashMap<>();
                objectInfo.put("header", headerTmp);
                throw new ServiceException(Common_ErrorsEnum.COMMON_6, "header._hzhr-user-code不能为空", objectInfo);
            }
            if (StringUtils.isEmpty(headerTmp.get("_hzhr-user-name"))) {
                Map<String, Object> objectInfo = new HashMap<>();
                objectInfo.put("header", headerTmp);
                throw new ServiceException(Common_ErrorsEnum.COMMON_6, "header._hzhr-user-name不能为空", objectInfo);
            }
            if (StringUtils.isEmpty(headerTmp.get("_hzhr-company-id"))) {
                Map<String, Object> objectInfo = new HashMap<>();
                objectInfo.put("header", headerTmp);
                throw new ServiceException(Common_ErrorsEnum.COMMON_6, "header._hzhr-company-id不能为空", objectInfo);
            }
            if (StringUtils.isEmpty(headerTmp.get("_hzhr-dept-id"))) {
                Map<String, Object> objectInfo = new HashMap<>();
                objectInfo.put("header", headerTmp);
                throw new ServiceException(Common_ErrorsEnum.COMMON_6, "header._hzhr-dept-id不能为空", objectInfo);
            }
            if (StringUtils.isEmpty(headerTmp.get("_hzhr-user-type"))) {
                Map<String, Object> objectInfo = new HashMap<>();
                objectInfo.put("header", headerTmp);
                throw new ServiceException(Common_ErrorsEnum.COMMON_6, "header._hzhr-user-type不能为空", objectInfo);
            }
            if (StringUtils.isEmpty(headerTmp.get("_hzhr-transaction-id"))) {
                Map<String, Object> objectInfo = new HashMap<>();
                objectInfo.put("header", headerTmp);
                throw new ServiceException(Common_ErrorsEnum.COMMON_6, "header._hzhr-transaction-id不能为空", objectInfo);
            }
            if (StringUtils.isEmpty(headerTmp.get("_hzhr-transaction-type"))) {
                Map<String, Object> objectInfo = new HashMap<>();
                objectInfo.put("header", headerTmp);
                throw new ServiceException(Common_ErrorsEnum.COMMON_6, "header._hzhr-transaction-type不能为空", objectInfo);
            }
            if (StringUtils.isEmpty(headerTmp.get("_hzhr-access-mode"))) {
                headerTmp.put("_hzhr-access-mode", "0");
            }
            if (StringUtils.isEmpty(queryTmp.get("_show_total"))) {
                queryTmp.put("_show_total", "false");
            }
            if (StringUtils.isEmpty(queryTmp.get("_show_info"))) {
                queryTmp.put("_show_info", "false");
            }
            if (StringUtils.isEmpty(queryTmp.get("_show_type"))) {
                queryTmp.put("_show_type", "false");
            }
            if (StringUtils.isEmpty(queryTmp.get("_show_iotDevice"))) {
                queryTmp.put("_show_iotDevice", "false");
            }
            if (StringUtils.isEmpty(queryTmp.get("_show_gasUser"))) {
                queryTmp.put("_show_gasUser", "false");
            }
            if (StringUtils.isEmpty(queryTmp.get("_show_gasConsume"))) {
                queryTmp.put("_show_gasConsume", "false");
            }
            if (StringUtils.isEmpty(queryTmp.get("_show_alarmCount"))) {
                queryTmp.put("_show_alarmCount", "false");
            }
            if (StringUtils.isEmpty(queryTmp.get("_show_dept"))) {
                queryTmp.put("_show_dept", "false");
            }
            if (StringUtils.isEmpty(queryTmp.get("_is_paging"))) {
                queryTmp.put("_is_paging", "false");
            }
            if (StringUtils.isEmpty(queryTmp.get("_page"))) {
                queryTmp.put("_page", "1");
            }
            if (StringUtils.isEmpty(queryTmp.get("_count"))) {
                queryTmp.put("_count", "1");
            }
        } else {
            if (StringUtils.isEmpty(headerTmp.get("_token"))) {
                Map<String, Object> objectInfo = new HashMap<>();
                objectInfo.put("header", headerTmp);
                throw new ServiceException(Common_ErrorsEnum.COMMON_6, "header.token不能为空", objectInfo);
            }
            if (StringUtils.isEmpty(queryTmp.get("_show_total"))) {
                queryTmp.put("_show_total", "false");
            }
            if (StringUtils.isEmpty(queryTmp.get("_show_info"))) {
                queryTmp.put("_show_info", "false");
            }
            if (StringUtils.isEmpty(queryTmp.get("_show_type"))) {
                queryTmp.put("_show_type", "false");
            }
            if (StringUtils.isEmpty(queryTmp.get("_show_iotDevice"))) {
                queryTmp.put("_show_iotDevice", "false");
            }
            if (StringUtils.isEmpty(queryTmp.get("_show_gasUser"))) {
                queryTmp.put("_show_gasUser", "false");
            }
            if (StringUtils.isEmpty(queryTmp.get("_show_gasConsume"))) {
                queryTmp.put("_show_gasConsume", "false");
            }
            if (StringUtils.isEmpty(queryTmp.get("_show_alarmCount"))) {
                queryTmp.put("_show_alarmCount", "false");
            }
            if (StringUtils.isEmpty(queryTmp.get("_show_dept"))) {
                queryTmp.put("_show_dept", "false");
            }
            if (StringUtils.isEmpty(queryTmp.get("_page"))) {
                queryTmp.put("_page", "1");
            }
            if (StringUtils.isEmpty(queryTmp.get("_count"))) {
                queryTmp.put("_count", "1");
            }
        }

        if (!StringUtils.isEmpty(queryTmp.get("_is_paging")) && !Boolean.parseBoolean(queryTmp.get("_is_paging").toString())) {
            queryTmp.put("_page", null);
            queryTmp.put("_count", null);
        }
        args[1] = queryTmp;
        args[0] = headerTmp;
        return joinPoint.proceed(args);
    }
}

